package com.ocom.mqsubsidy.controller;

import com.ocom.common.constant.MqPay;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.RandomUtil;
import com.ocom.common.utils.ResultUtil;
import com.ocom.common.vo.webapi.ExcelCouponsVoucherListVo;
import com.ocom.mqsubsidy.business.coupons.ImportCouponsVoucherService;
import com.ocom.redis.util.RedisUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class importCouponsVoucherController {
    @Resource
    private RedisUtil redisUtil;
    @Resource
    private ImportCouponsVoucherService importCouponsVoucherService;

    @PostMapping(MqPay.URL_importCouponsVoucher)
    public Result importCouponsVoucher(@RequestBody ExcelCouponsVoucherListVo request){
        String mqKey = "MqSubsidy:importCouponsVoucher:"+ System.currentTimeMillis()+ RandomUtil.getRandomString(20);
        redisUtil.set(mqKey,request,7300l);
        importCouponsVoucherService.handle(mqKey);
        return ResultUtil.success();
    }
}
